<?php
require_once BASE_PATH.'application/models/basedao'.EXT;

class buscadorDAO extends baseDAO {

	var $table = 'k2_items';
	var $key   = 'id';
	var $sql   = '';

	function __construct()
	{
            
	    // Call the Model constructor
	    parent::__construct();
	}

	function _defaultSQL()
	{
		$this->db->where(array("published"=>1,"trash"=>0));	
    $this->db->where('fulltext <>',"");
	}
  
  function _orderNota($orden)
  {
      switch($orden)
      {
        case 1:
          $this->db->order_by('created','DESC');
        break;
        
        case 2:
          $this->db->order_by('hits','DESC');
        break;
        
        case 3:
          $this->db->order_by('raiting','DESC');
        break;
        
        case 4:
          $this->db->order_by('comments','DESC');
        break;
        
        default:
        break;
      }
  }
  
  
  function getBusqueda($busqueda,$filtro)
  {
    $this->_defaultSQL();
    $this->db->or_like('title',$busqueda);
    $this->db->or_like('introtext',$busqueda);
    $this->db->or_like('fulltext',$busqueda);
    $this->_orderNota($filtro);
    return $this->select();
  }

  function select($data=array())
	{
		return $this->_select($data);
	}
}

?>